<extend name="layout/edit" />

<block name="HEADER">
	
</block>

<block name="CONTENT">
    <control:form id="form"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
		ns.init = function(){

            ns.showstaff();

        }

        //其他工资 - 删除
        ns.deletestaff = function(){
            form.$grids['otherstaffGrid'].deleteRow();
        }


        //为增加行
        ns.addstaff = function(){
            form.$grids['otherstaffGrid'].addRow([{
                other_staff:'',
                money:'',
            }]);
        }

        //显示填充具体工资
        ns.showstaff =  function(){
            var staff_Info=parent.window.staffInfo;
            form.setFormValue(staff_Info);
            form.setValue('id',$.getRequest("id"));
            form.setValue('months',$.getRequest("months"));
            form.setValue('staff_id',staff_Info.id);
            form.setValue('shop_id',$.getRequest("shop_id"));
        }


        //保存
        ns.save=function(){   
        	var data = form.getData();

        	if(!data) return false;
            form.save(4).then(function(res){
                $.ajaxs('/admin/v1/shop_staff/addOtherStaff',{
                    id:res.data,
                    form_data:form.getData(),
                    staffData: JSON.stringify(form.$grids['otherstaffGrid'].getRows())
                }).then(function(res){
                    form.opener.$.toast(1,'保存成功！');
                    form.opener.grid.load();
                    $.close();
                });
            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>




